package com.winit.openapi.tms.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSONObject;
import com.winit.common.utils.Dates;
import com.winit.openapi.controller.BaseController;
import com.winit.openapi.model.RequestMsg;
import com.winit.openapi.model.ResponseMsg;
import com.winit.openapi.util.ValidateUtil;
import com.winit.tms.spi.pickup.PickOrderService;
import com.winit.tms.spi.pickup.command.PrintPickOrderLableCommand;
import com.winit.tms.spi.pickup.vo.PrintPickOrderLableVo;

/**
 * 打印提货单面单
 * 
 * @version <pre>
 * Author	Version		Date		Changes
 * jianhua.huang 	1.0  		2015-11-26 	Created
 * 
 * </pre>
 * @since 1.
 */
@Controller
@RequestMapping(value = "/tms/printPickOrder")
public class PrintPickOrderLableController extends BaseController {

	@Resource
	private PickOrderService pickOrderService;

	@RequestMapping(value = "/printLable")
	public String printLable(@ModelAttribute RequestMsg requestMsg,
			@ModelAttribute ResponseMsg responseMsg) {
		 // 获取参数
        JSONObject json = JSONObject.parseObject(requestMsg.getData().toString());
        //验证参数
        ValidateUtil.validNotNull(json, "orderNO");
        PrintPickOrderLableCommand command=new PrintPickOrderLableCommand();
        command.setOrderNO(json.getString("orderNO"));
        command.setPrintdate(Dates.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
        PrintPickOrderLableVo lableVo= pickOrderService.printPickOrderLable(command);
        Map<String, Object> dataMap = new HashMap<String, Object>();
        dataMap.put("statusCode", lableVo.getStatusCode());
        dataMap.put("files", lableVo.getFileName());
        responseMsg.setData(dataMap);
		return SUCCESS;
	}
}
